class Solution {
public:
    int calPoints(vector<string>& operations) {
        int n = operations.size();
        vector<int>res;
        for (auto x : operations) {
            if (x != "C" && x != "D" && x != "+") {
                res.push_back(stoi(x));
            }
            else if (x == "C") {
                res.pop_back();
            }

            else if (x == "D") {
                int z = res.size();
                int t = res[z - 1];
                res.push_back(t * 2);
                cout << res.size() << endl;
                cout << "t==" << t << endl;
            }
            else if (x == "+") {
                int z = res.size();
                int k = res[z - 1] + res[z - 2];
                res.push_back(k);
            }
        }
        int ans = 0;
        for (auto x : res) {
            ans += x;
        }
        return ans;
    }
};